home *** CD-ROM | disk | FTP | other *** search
/ Java Certification Exam Guide / McGrawwHill-JavaCertificationExamGuide.iso / pc / Web Links and Code / code / chap4 / Acc.java next >
Encoding:
Java Source  |  1997-04-19  |  348 b   |  22 lines

  1. class Acc {
  2.    public static void main(String[] args) {
  3.       First s = new Second();
  4.       System.out.println(s.var);
  5.       System.out.println(s.method());
  6.    }
  7. }
  8.  
  9. class First {
  10.    int var = 1;
  11.    int method() {
  12.       return var;
  13.    }
  14. }
  15.  
  16. class Second extends First {
  17.    int var = 2;
  18.    int method() {
  19.       return var;
  20.    }
  21. }
  22.